home *** CD-ROM | disk | FTP | other *** search
/ Network Supervisor's Toolkit / Network Supervisor's Toolkit.iso / tools / lu62 / port / keycur.h < prev    next >
Text File  |  1996-07-10  |  6KB  |  256 lines

  1. /* k 0184    18/06/91    */
  2. /* k 0189    27/06/91    */
  3. /* k 0190    28/06/91    */
  4. /* k 0199    18/08/91    *//* OS_TYPE */
  5. /* k 0199 */
  6. /* k 0222    18/09/91    */
  7. /* k 0224       23/09/91        *//* ebss */
  8. /* k 0230       09/10/91        *//* assemble some data */
  9. #include <ebss.h>               /* @0224 */
  10. #if (OVL_TYPE!=1)
  11. #include <stdlib.h>
  12. #include <stdio.h>
  13. #include <fcntl.h>    /* @0184 */
  14. #include <string.h>
  15. #endif
  16. #if ((OS_TYPE!=3)&&(OS_TYPE!=4))
  17. #endif        /* @0184 */
  18. #include "pconio.h"
  19.  
  20. #if (OS_TYPE==4)
  21. #include <sys/machdep.h>
  22. #include <sgtty.h>
  23. #include <sys/comcrt.h>
  24. #define sotofar(seg, off) (((char far *) (((long)(unsigned) (seg)) << 16)) + (unsigned) (off))
  25. #endif
  26. /* @0230 */
  27. #define MK_FP(seg,ofs)    ((void far *) \
  28.                (((unsigned long)(seg) << 16) | (unsigned)(ofs)))
  29. #define FP_SEG(fp)      ((unsigned)(void _seg *)(void far *)(fp))
  30. #define FP_OFF(fp)      ((unsigned)(fp))
  31.  
  32. void writef();    /* @0184 */
  33. void setcolor();    /* @0184 */
  34. void setcursor();    /* @0184 */
  35. unsigned int getcursor();    /* @0184 */
  36. void changecursor();    /* @0184 */
  37. void initcursor();    /* @0184 */
  38. void initcolortable();    /* @0184 */
  39.  
  40. #if ((OS_TYPE==3) || (OS_TYPE==4))
  41. unsigned iint adaptIO,adaptMD,adaptMAP;
  42. char far *videobuf;
  43. #endif
  44.  
  45.  
  46.  
  47. int check_mode ( ) {
  48. #if ((OS_TYPE!=3)&&(OS_TYPE!=4))
  49.  struct text_info ti;
  50.  
  51.  union REGS reg;
  52.  
  53.  reg.h.ah = 15;
  54. #if ((OVL_TYPE==1)&&(RESIDENT!=1))
  55.  Res_int86(0X10, ®, ®);
  56. #else
  57.  int86(0X10, ®, ®);
  58. #endif
  59.  if (reg.h.al==7) return 0;
  60.  return 1;
  61. #elif (OS_TYPE==3)
  62. #define TCGMODE ('T'<<8|10)
  63. struct tty_mode {
  64.   unsigned char tm_cap
  65.   unsigned char tm_adaptor;
  66.   unsigned char tm_colmode;
  67.   unsigned char tm_colsel;
  68. }  mode;
  69.  ioctl (0,TCGMODE,&mode);
  70.  return (mode.tm_adaptor);  /* 0 - MONO */ 
  71. #elif (OS_TYPE==4)
  72. if ( ioctl (0,CONS_GET,0)==MONO)
  73.            return 0;
  74. return 1;
  75. #endif
  76. }
  77.  
  78.  
  79.  
  80.  
  81.  void outscreen(buf,offset,len)
  82. char *buf;    /* @0184 */
  83. int offset;    /* @0184 */
  84. int len;    /* @0184 */
  85.      {
  86.       char far *pt;  
  87.       int j,i=2*offset;
  88.       char *w=buf+i;
  89. #if (OS_TYPE==4)
  90.       pt=videobuf+i;
  91. #else
  92.       pt=MK_FP(vissegment,i);
  93. #endif
  94.     for (j=0;j<2*len;j++)
  95.          *pt++=*w++;
  96. /*     movedata(FP_SEG(buf+i),FP_OFF(buf+i),vissegment,i,2*len); */
  97.      }
  98.  
  99.  void inscreen(buf,offset,len)
  100. char *buf;    /* @0184 */
  101. int offset;    /* @0184 */
  102. int len;    /* @0184 */
  103.      {
  104.       char far *pt;
  105.       int j,i=2*offset;
  106.       char far *w=buf+i;
  107. #if (OS_TYPE==4)
  108.       pt=videobuf+i;
  109. #else
  110.       pt=MK_FP(vissegment,i);
  111. #endif
  112.     for (j=0;j<2*len;j++)
  113.          *w++=*pt++;
  114.      }
  115.  
  116. void setcursor(shape)    /* @0184 */
  117. unsigned int shape;    /* @0184 */
  118. /* Sets the shape of the cursor */
  119. {
  120. #if ((OS_TYPE !=3)&&(OS_TYPE!=4))
  121.  union REGS reg;
  122.  
  123.  reg.h.ah = 1;
  124.  reg.x.cx = shape;
  125. #if ((OVL_TYPE==1)&&(RESIDENT!=1))
  126.  Res_int86(0X10, ®, ®);
  127. #else
  128.  int86(0X10, ®, ®);
  129. #endif
  130. #else
  131. #if ((OS_TYPE==3)||(OS_TYPE==0))
  132. unsigned char b1=shape & 0xFF;
  133. unsigned char b2=shape >> 8;
  134. #if ((OVL_TYPE==1)&&(RESIDENT!=1))
  135.  Res_outp (baseport,0x0b);
  136.  Res_outp (baseport+1,b1);
  137.  Res_outp (baseport,0x0a);
  138.  Res_outp (baseport+1,b2);
  139. #else
  140.  outp (baseport,0x0b);
  141.  outp (baseport+1,b1);
  142.  outp (baseport,0x0a);
  143.  outp (baseport+1,b2);
  144. #endif
  145. #else
  146. struct port_io_arg depoz;
  147. unsigned char b1=shape & 0xFF;
  148. unsigned char b2=shape >> 8;
  149.  depoz.args[0].dir=OUT_ON_PORT;
  150.  depoz.args[0].port=baseport;
  151.  depoz.args[0].data=0x0b;
  152.  depoz.args[1].dir=OUT_ON_PORT;
  153.  depoz.args[1].port=baseport+1;
  154.  depoz.args[1].data=b1;
  155.  depoz.args[2].dir=OUT_ON_PORT;
  156.  depoz.args[2].port=baseport;
  157.  depoz.args[2].data=0x0a;
  158.  depoz.args[3].dir=OUT_ON_PORT;
  159.  depoz.args[3].port=baseport+1;
  160.  depoz.args[3].data=b2;
  161.  ioctl (0,adaptIO,&depoz);
  162. #endif
  163. #endif
  164. } /* setcursor */
  165.  
  166. unsigned int getcursor()    /* @0184 */
  167. /* Returns the shape of the current cursor */
  168. {
  169. #if ((OS_TYPE !=3)&&(OS_TYPE!=4))
  170.  union REGS reg;
  171.  
  172.  reg.h.ah = 3;
  173.  reg.h.bh = 0;
  174. #if ((OVL_TYPE==1)&&(RESIDENT!=1))
  175.  Res_int86(0X10, ®, ®);
  176. #else
  177.  int86(0X10, ®, ®);
  178. #endif
  179.  return(reg.x.cx);
  180. #else
  181.  if (check_mode()) return (0x0607);
  182.  else return (0x0A0C);
  183. #endif
  184. } /* getcursor */
  185.  
  186.  
  187. void setcolor(color)    /* @0184 */
  188. int color;    /* @0184 */
  189. /* Sets the current color using the color table */
  190. {
  191.   textattr(colortable[color]);
  192. } /* setcolor */
  193.  
  194.  
  195. void writef(col,row,color,width,string)    /* @0184 */
  196. int col;    /* @0184 */
  197. int row;    /* @0184 */
  198. int color;    /* @0184 */
  199. int width;    /* @0184 */
  200. char * string;  /* @0184 */
  201. /* Prints a string in video memory at a selected location in a color */
  202. {
  203.  char output[81],*ppp; int i,j;
  204.  
  205. #if ((OVL_TYPE==1)&&(RESIDENT!=1))
  206.  int len=Res_strlen(string);
  207. #else
  208.  int len=strlen(string);
  209. #endif
  210.  if (len>80) len=80;
  211. #if ((OVL_TYPE==1)&&(RESIDENT!=1))
  212.  Res_memcpy (output, string, len);
  213. #else
  214.  memcpy (output, string, len);
  215. #endif
  216.  output[width] = 0;
  217.  if (len  < width) {
  218.   j=width-len;
  219.   ppp=output+len;
  220.   for (i=0;i<j;i++)
  221.         *ppp++=' ';
  222.   }
  223.  setcolor(color);
  224.  gotoxy(col, row);
  225.  cprintf(output);
  226.   return;
  227. } /* writef */
  228.  
  229. void changecursor(insmode)
  230. /* Changes the cursor shape based on the current insert mode */
  231. {
  232.  if (insmode)
  233.   setcursor(tallcursor);
  234.  else
  235.   setcursor(shortcursor);
  236. } /* changecursor */
  237.  
  238. #if (OS_TYPE==4)
  239. sh_vt()        /* @0190 */
  240. {               /* @0190 */
  241.   struct sgttyb argum;        /* @0190 */
  242.     gtty(0,&argum);        /* @0190 */
  243.     argum.sg_flags|=RAW;    /* @0190 */
  244.     argum.sg_flags&=~ECHO;    /* @0190 */
  245.     stty(0,&argum);        /* @0190 */
  246. }                /* @0190 */
  247. vt_sh()                /* @0190 */
  248. {                /* @0190 */
  249.   struct sgttyb argum;        /* @0190 */
  250.     gtty(0,&argum);        /* @0190 */
  251.     argum.sg_flags&=~RAW;    /* @0190 */
  252.     argum.sg_flags|=ECHO;    /* @0190 */
  253.     stty(0,&argum);        /* @0190 */
  254. }                /* @0190 */
  255. #endif
  256.